/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-08-01
 * Time: 23:09
 */
public class Main {
    public int removeDuplicates(int[] nums) {
        int slow = 1;
        int fast ;
        for (fast = 1; fast < nums.length; fast++) {
            if (nums[fast] != nums[slow - 1]) {
                nums[slow] = nums[fast];
                slow++;
            }
        }
        return slow;
    }
    public int removeDuplicates1(int[] nums) {
        int i=0,j=0;
        int temp=nums[0];
        while(i<nums.length){
            if(i==0||nums[i]!=temp){
                nums[j]=nums[i];
                j++;
            }
            temp=nums[i];
            i++;
        }return j;
    }
}
